<template>
	<view class="container">
		<view class="orderList">

			<view class="orderItem" v-for="item in orderList" :key="item.id">
				<view class="orderHd">
					日期：{{item.create_time}}
				</view>
				<view class="orderCon">
					<view class="oSpread">客户编码：{{item.buyer.spread_code}} <span @click="copy(item.buyer.spread_code)" class="copy">复制</span></view>
					<view class="oPrice">单价：<text>￥{{item.goods_price}}</text></view>
					<view class="oNum">数量：{{item.num}}</view>
				</view>
				<view class="orderFooter">
					<view>总价：￥{{item.total_price}}</view>
				</view>
			</view>

		</view>
		<u-loadmore :status="status" />
	</view>
</template>

<script>
	import {
		stockTransferList
	} from "@/common/api.js";
	export default {
		components: {},
		data() {
			return {
				page: 1,
				status: 'loadmore',
				orderList: []
			};
		},
		onLoad() {
			this.selectOrder()
		},
		onReachBottom() {
			this.selectOrder()
		},
		methods: {
			copy(text){
				uni.setClipboardData({
					data:text
				})
			},
			selectOrder() {
				stockTransferList(this, {
					page: this.page
				}, (res) => {
					this.$set(this, 'orderList', [...this.orderList, ...res])
					this.page++
					this.status = 'loadmore'
					if (res.length === 0) {
						this.status = 'nomore'
					}
				})
			}
		}
	};
</script>
<style lang="scss">
	page {
		font-family: PingFang SC;
		background-color: #F6F6F6;
		height: 100%;
	}

	.orderItem {
		margin: 15rpx 15rpx 25rpx 15rpx;
		border-radius: 15rpx;
		background-color: #FFFFFF;

		.orderHd {
			height: 60rpx;
			line-height: 60rpx;
			color: #999999;
			padding: 0 15rpx;
			border-bottom: 1rpx solid #efefef;
			overflow: hidden;
			font-size: 12px;
		}

		.orderCon {
			padding: 15rpx;

			.oTel {
				height: 50rpx;
				font-size: 16px;
				color: #333;
			}

			.oSpread {
				height: 50rpx;
				font-size: 14px;
				color: #333;
			}

			.oPrice {
				height: 50rpx;
				font-size: 14px;
				color: #333;

				text {
					color: #FF0000;
				}
			}

			.oNum {
				color: #999999;
				font-size: 12px;
				height: 50rpx;
				line-height: 50rpx;
			}

			.oRemain {
				color: #999999;
				font-size: 12px;
				height: 50rpx;
				line-height: 50rpx;
			}
		}

		.orderFooter {
			border-top: 1rpx solid #efefef;
			color: #999999;
			line-height: 60rpx;
			text-align: right;
			padding: 15rpx;

			.btns {
				overflow: hidden;
			}

			.btn {
				font-size: 12px;
				border: 1rpx solid #d5d5d5;
				display: inline-block;
				border-radius: 10rpx;
				float: right;
				margin-left: 20rpx;
				padding: 0 15rpx;
				line-height: 50rpx;
			}
		}
	}
	.copy{
		margin-left: 30rpx;
	}
</style>